<?php
    namespace Spider\network;

    use lactone\Core\data\SocketData;
    use lactone\Core\network\ClientInstance;

    class SpiderToServer extends ClientInstance{

        protected $taskQueue;

        public function run(){
            $this->initClient(false);

            swoole_timer_tick(\Lactone::SPIDERLIVETIME*1000,array($this,'SendLiveInfo'));
        }

        /**
         * 发送蜘蛛存活数据到客服务端
         */
        public function SendLiveInfo(){

            if(!$this->isConnect){
                $this->initClient(false);
                return false;
            }

            $data = new SocketData();

            $data->create(\Lactone::getConfig('Spider\network\Server'),\Lactone::SPIDERLIVEACTION);

            $this->Send($data->__toString());

            unset($data);
        }

    }